﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/26/2009
 * Time: 4:39 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Generic;
using Miming.Model;

namespace Miming.Gui
{
	/// <summary>
	/// Description of SalesTaxCodeForm.
	/// </summary>
	public partial class SalesTaxCodeForm : BaseForm
	{
		public SalesTaxCodeForm() : this(new SalesTaxCode())
		{
			
		}
		
		public SalesTaxCodeForm(SalesTaxCode c)
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			Model = c;
		}
		
		protected override void OnModelChanged(EventArgs e)
		{
			base.OnModelChanged(e);
			SalesTaxCode c = Model as SalesTaxCode;
			textBoxCode.Text = c.Code;
			textBoxDescription.Text = c.Description;
			radioButtonTaxable.Checked = c.Taxable;
			checkBoxInactive.Checked = c.Inactive;
		}
		
		void ButtonOkClick(object sender, EventArgs e)
		{
			SalesTaxCode c = Model as SalesTaxCode;
			c.Code = textBoxCode.Text;
			c.Description = textBoxDescription.Text;
			c.Taxable = radioButtonTaxable.Checked;
			c.Inactive = checkBoxInactive.Checked;
			SessionFacade.SaveOrUpdateSalesTaxCode(c);
			Close();
		}
		
		void ButtonCancelClick(object sender, EventArgs e)
		{
			Close();
		}
	}
}
